package com.baseLesson._03_io;

import java.io.*;

public class _05_BufferStream {
    public _05_BufferStream() {
    }

    public static void main(String[] args) {
        write();
    }

    public static void write()  {
        File file = new File("data/write.txt");

        try {
            OutputStream os = new FileOutputStream(file);
            BufferedOutputStream bos = new BufferedOutputStream(os);
            String content = "我第一次用代码向文件中写入内容！，我的第一次就这样没有了！！！ \r\n";
            long startTime = System.currentTimeMillis();

            for(int i = 1; i <= 100; ++i) {
                bos.write(content.getBytes());
            }

            long endTime = System.currentTimeMillis();
            System.out.println("costTime:" + (endTime - startTime) + "毫秒");
            bos.close();
            System.out.println("写入内容成功！！！");
        } catch (FileNotFoundException var8) {
            var8.printStackTrace();
        } catch (IOException var9) {
            var9.printStackTrace();
        }
    }
}
